package com.bigevent.bigevent.mapper;

import com.bigevent.bigevent.entity.Article;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author yangxudong
 * @description:
 * @date 2024/2/10 11:26
 */
@Mapper
public interface ArticleMapper {
    @Insert("insert into article(title,content,cover_img,state,category_id,create_user,create_time,update_time)" +
            " values(#{title},#{content},#{coverImg},#{state},#{categoryId},#{createUser},now(),now())")
    void registArticle(Article article);

    List<Article> getArticleList(Integer userId, Integer categoryId, String state);

    void updateArticle(Article article);

    @Select("select * from article where id = #{id}")
    Article getArticleDetail(Integer id);

    @Delete("delete from article where id = #{id}")
    void deleteArticle(Integer id);
}
